import java.util.Scanner;


public class Test1018 {

    public static void main(String[] args) {

        Player A = new Player();
        Player B = new Player();

        Scanner input = new Scanner(System.in);

        int count = input.nextInt();

        for (int i = 0; i < count; i++) {
            char a = input.next().charAt(0);
            char b = input.next().charAt(0);
            A.record(a, b);
            B.record(b, a);
        }

        A.print();
        B.print();

        System.out.print(A.max() + " " + B.max());
    }
}


class Player {

    private int B, C, J;
    private int[] score = new int[3];

    public Player() {
        this.B = 0;
        this.C = 0;
        this.J = 0;
        this.score[0] = 0; // win
        this.score[1] = 0; // tie
        this.score[2] = 0; // lose
    }

    public void record(char a, char b) {
        switch (a) {
            case 'B':
                switch (b) {
                    case 'B':
                        this.score[1]++;
                        break;
                    case 'C':
                        this.B++;
                        this.score[0]++;
                        break;
                    case 'J':
                        this.score[2]++;
                        break;
                }
                break;
            case 'C':
                switch (b) {
                    case 'B':
                        this.score[2]++;
                        break;
                    case 'C':
                        this.score[1]++;
                        break;
                    case 'J':
                        this.C++;
                        this.score[0]++;
                        break;
                }
                break;
            case 'J':
                switch (b) {
                    case 'B':
                        this.J++;
                        this.score[0]++;
                        break;
                    case 'C':
                        this.score[2]++;
                        break;
                    case 'J':
                        this.score[1]++;
                        break;
                }
                break;
        }
    }

    public String max() {
        if (this.B >= this.C && this.B >= this.J)
            return "B";
        else if (this.C > this.B && this.C >= this.J)
            return "C";
        else
            return "J";
    }

    public void print() {
        System.out.printf("%d %d %d\n", score[0], score[1], score[2]);
    }
}
